/*
 * @Date: 2020-08-24 13:47:09
 * @LastEditors: xujianxing
 * @LastEditTime: 2020-08-24 14:28:57
 * @FilePath: \nili\src\common\middleware\Logger.middleware.ts
 */
import { NestMiddleware } from '@nestjs/common';
import { Request, Response } from 'express';

/**
 * 类中间件
 */
export class LoggerMiddleware implements NestMiddleware {
  use(req: Request, res: Response, next: () => void) {
    console.debug(`request url: ${req.url}, methods: ${req.method}`);
    next();
  }
}

/**
 * 函数中间件
 * @param req 请求体
 * @param res 响应体
 * @param next 继续执行
 */
export function LoggerFunc(req: Request, res: Response, next: Function) {
  console.debug('----func logger----');
  next();
}
